How to configure PlatformIO for ESP32-SOLO-1? - esp32

I've a simple led blinking example which I'm trying to run on a ESP32-SOLO-1 but as soon I flash it with the program I get the following message from the serial monitor:
E (102) cpu_start: Running on single core chip, but application is built with dual core support.
E (102) cpu_start: Please enable CONFIG_FREERTOS_UNICORE option in menuconfig.
abort() was called at PC 0x400829d2 on core 0
Here's the code
#include <Arduino.h>
#define LED_BUILTIN 2
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
And the platformio.ini config:
[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
monitor_speed = 115200
framework = arduino
build_flags = -D CONFIG_FREERTOS_UNICORE
Adding the build flag CONFIG_FREERTOS_UNICORE has no effect.

Related

ESP32 Welcome screen transition to another screen?

I'm making a simple car gauge, I want to add a little personal touch nothing special.
Setup: ESP32 and ST7735S with no SD card.
At the beginning I want to add a boot screen ( picture- I use flash memory for this because I have no SD card tftIcons.ino)
After like 5s I want to transition from picture to my gauges ( simple print code for now) But I don't know how to stich these two together to get what I want.
The code for Welcome screen/ Boot is:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include "bitmaps.h"
#include "bitmapsLarge.h"
// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define TFT_CS 5
#define TFT_RST 4 // you can also connect this to the Arduino reset
// in which case, set this #define pin to 0!
#define TFT_DC 2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.initR(INITR_BLACKTAB);
tft.setRotation(0);
tft.fillScreen(ST7735_BLACK);
//Case 2: Multi Colored Images/Icons
int h = 160,w = 128, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(evive_in_hand + buffidx));
buffidx++;
} // end pixel
}
}
void loop() {
}
The code for the gauges is:
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#define TFT_CS 5
#define TFT_RST 4 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
tft.setRotation(1); // set display orientation
}
void loop() {
tft.fillScreen(ST77XX_BLACK);
print_text(20,5,"1.54",5,ST77XX_GREEN);
print_text(70,50,"BAR",2,ST77XX_GREEN);
print_text(5,90,"Temp motora: 81'C",1,ST77XX_WHITE);
print_text(5,100,"Temp usisa: 30'C",1,ST77XX_BLUE);
print_text(146,116,"AM",1,ST77XX_WHITE);
delay(5000);
}
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
tft.setCursor(x_pos, y_pos);
tft.setTextSize(text_size);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
Can someone tell me how can I make when I power on ESP32 to show Welcome screen/ boot screen for 5s, then automatically transition to Gauges screen ?
EDIT: When I join these two
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include "bitmaps.h"
#include "bitmapsLarge.h"
// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define TFT_CS 5
#define TFT_RST 4 // you can also connect this to the Arduino reset
// in which case, set this #define pin to 0!
#define TFT_DC 2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.initR(INITR_BLACKTAB);
tft.setRotation(0);
tft.fillScreen(ST7735_BLACK);
//Case 2: Multi Colored Images/Icons
int h = 160,w = 128, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(evive_in_hand + buffidx));
buffidx++;
} // end pixel
}
delay(5000); // Delay 5s, then run the code down?
}
// Timer
float p = 3.1415926;
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
tft.setRotation(1); // set display orientation
void loop() {
tft.fillScreen(ST77XX_BLACK);
print_text(20,5,"1.54",5,ST77XX_GREEN);
print_text(70,50,"BAR",2,ST77XX_GREEN);
print_text(5,90,"Temp motora: 81'C",1,ST77XX_WHITE);
print_text(5,100,"Temp usisa: 30'C",1,ST77XX_BLUE);
print_text(146,116,"AM",1,ST77XX_WHITE);
delay(5000);
}
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
tft.setCursor(x_pos, y_pos);
tft.setTextSize(text_size);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
I get exit status 1
'Serial' does not name a type
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include "bitmaps.h"
#include "bitmapsLarge.h"
#define TFT_CS 5
#define TFT_RST 4 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
tft.initR(INITR_BLACKTAB);
tft.setRotation(0);
tft.fillScreen(ST7735_BLACK);
//Case 2: Multi Colored Images/Icons
int h = 160,w = 128, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(evive_in_hand + buffidx));
buffidx++;
} // end pixel
}
delay(5000);
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
tft.setRotation(1); // set display orientation
}
void loop() {
tft.fillScreen(ST77XX_BLACK);
print_text(20,5,"1.54",5,ST77XX_GREEN);
print_text(70,50,"BAR",2,ST77XX_GREEN);
print_text(5,90,"Temp motora: 81'C",1,ST77XX_WHITE);
print_text(5,100,"Temp usisa: 30'C",1,ST77XX_BLUE);
print_text(146,116,"AM",1,ST77XX_WHITE);
delay(5000);
}
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
tft.setCursor(x_pos, y_pos);
tft.setTextSize(text_size);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
I fount out how. You can only have one void setup and void loop. You cant c/p stich two together

ESP32 with max98357a board works. But I can't use void loop() function for other purposes

I have been learning how to program in esp32 using arduino IDE.
I couldn't figure out how to use max98357a board with Esp32-DevKitC. I have tried "Audio.h" and "AudioTools.h" libraries but not is changed.
My first attempt was just testing voice output. My code is below:
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
// Digital I/O used
#define I2S_DOUT 26 // DIN connection
#define I2S_BCLK 27 // Bit clock
#define I2S_LRC 14 // Left Right Clock
Audio audio;
String ssid = "MYCROFT";
String password = "145678abc789";
void setup() {
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED) delay(1500);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // 0...21
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");
// audio.connecttohost("http://macslons-irish-pub-radio.com/media.asx");
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.aac"); // 128k aac
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); // 128k mp3
audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3"); // 128k mp3
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
// audio.connecttohost("http://media.ndr.de/download/podcasts/podcast4161/AU-20190404-0844-1700.mp3"); // podcast
}
void loop()
{
audio.loop();
}
It works as intended but when I try to add some commands to the loop function, It stops working.
I mean if I change the loop function as below, it stops connecting to the audio stream.
void loop()
{
delay(3000);
Serial.println("Hello");
audio.loop();
}
Is it possible to use max98357a with some additional codes apart from just simple audio.loop().
The delay(3000) instruction causes the microprocessor to do nothing but sit & wait for 3 seconds. Not even interrupts are serviced so audio is lost.

HC-05 with Arduino Uno send data from phone to hc-05

I am trying to use a hc-05 module for the first time and I have some problems: I already had a hard time finding the right pins for the rx and tx pin that g finally put on rx -> pin0 (rx) and tx -> pin 10.
I can send data from the hc-05 to the phone but if I send from the phone to the hc-05 I get weird characters. Here is my code and the configuration. Thank you for your help. [configuration image][1]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 0); // RX, TX
void setup() {
Serial.begin(9600);
pinMode(9,OUTPUT); digitalWrite(9,HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(38400);
}
void loop()
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}```
[1]: https://i.stack.imgur.com/BhED7.jpg
In fact it is enough just to put the baud rate of the HC-05 also to 9600.

ESP32 failing to detect PN532 NFC module

I've been struggling for the past few days to get the Elechouse PN532 V3 module working with an ESP32 over I2C. The PN532 module itself works fine with a Raspberry Pi.
This is the circuit (not actually using SparkFun ESP32 board, just for reference)
And this is the code I'm trying to run
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);
void setup(void) {
Serial.begin(115200);
Serial.println("Hello!");
Wire.begin(18, 19);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// Set the max number of retry attempts to read from a card
// This prevents us from waiting forever for a card, which is
// the default behaviour of the PN532.
nfc.setPassiveActivationRetries(0xFF);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A card");
}
void loop(void) {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
if (success) {
Serial.println("Found a card!");
Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print("UID Value: ");
for (uint8_t i=0; i < uidLength; i++)
{
Serial.print(" 0x");Serial.print(uid[i], HEX);
}
Serial.println("");
// Wait 1 second before continuing
delay(1000);
}
else
{
// PN532 probably timed out waiting for a card
Serial.println("Timed out waiting for a card");
}
}
And finally the serial output: Didn't find PN53X board
Any ideas what I'm doing wrong?
EDIT: libraries im using https://github.com/elechouse/PN532 and the ESP32 dev board is a Wemos Lolin32 Lite clone.
I don't have any of this hardware to verify this, but from 'PN532-PN532_HSU\NDEF\README.md'
For the Adafruit Shield using I2C
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
Try using the above in your code? I'd also suggest you review the PN532 I2C examples in more depth. The PN532 I2C library code defines a 'wakeup' function:
void PN532_I2C::wakeup()
{
delay(500); // wait for all ready to manipulate pn532
}
The comment makes me believe the device may require a significant delay (500ms) before it's ready to talk.
Best of luck.
sda and scl are 21 and 22
also make sure that you changed mode to I2C (those jumpers on PN532 module):
doc - page 3
I have this now working with an M5STACK grey core, the common issue was the I2C bus would lock up on a reset or re program. Use a spare I/O pin and connect to the PN532 reset pin, hold this low on boot, initialize I2C bus then drive reset high after 100mS problem solved no more bus conflicts.

Processor has been reset by watch dog timer (PIC16F72, XC8 compiler)

I have started PIC programming for PIC16F72 micro-controller through MPLAB X IDE and XC8 compiler.Below is my code, it is compiled successfully.
#define _XTAL_FREQ 4000000
#include<xc.h>
#pragma config FOSC = RC // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
char pattern[] = {0b10000001,0b11000011,0b11100111,0b11111111,0b11100111,0b11000011,0b10000001};
void write(char tab)
{
char check;
for(int a=0;a<8;a++)
{
check = ((tab >> a) & 1);
if(check)
{
PORTBbits.RB7=1;
PORTBbits.RB6=0;PORTBbits.RB6=1;
}
else
{
PORTBbits.RB7=0;
PORTBbits.RB6=0;PORTBbits.RB6=1;
}
}
}
void main(void) {
TRISB=0x00; //Initialize as output
PORTBbits.RB6=0;
PORTBbits.RB5=0;
PORTBbits.RB5=1;
while(1)
{
for(int i=0;i<7;i++)
{
write(pattern[i]);
__delay_ms(1000);
}
}
return;
}
When I simulated my code in Proteus it shows below error
Processor has been reset by watch dog timer expiring at xxxxx after every 2.3 seconds.
I have searched for this problem with no success. I am unable to resolve the issue
you forget a letter. You have...
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
it should be
#pragma config WDTEN = OFF
Check out page 60 of the datasheet
Try with
__CONFIG(_WDT_OFF & _PWRTE_ON)
Instead of using #pragma config
You can try to use MPLAB X to generate configuration bits for you.
In MPLAB X, click Window -> PIC Memory Views -> Configuration Bits. New window will show up where you can configure your PIC and disable watchdog. If you click button "Generate Source Code to Output" MPLAB will generate source code with proper Configuration Bits for PIC you're using in project. Here's official Microchip tutorial which describes it in detail -http://microchipdeveloper.com/mplabx:view-and-set-configuration-bits
Proteus, the simulation tool, is not officially provided by microchip (chip manufacturer), also sometimes the pirated copy of software creates issues, one thing you can try is double click on the microcontroller in Proteus and change the configuration word to what you actually want. I suggest you to test the code on physical microcontroller.

Resources