Hello Friends,
I have a Problem with my project.
I use this Arduino Mega Board with build in ESP8266:
After flashing the ESP8266 with the latest AT Firmware that is supportet by Blynk (>see getting startet)
everything works fine.
The ESP connects to blynk, i can upload a sketch to the mega, and my blink app shows me my sensor data.
now i want to get the signal strengh printet to the serial monitor and to virtual pin V7.
the problem is, that the value is everytime “0”.
do this lib wiFi.h dont work with the esp? or what do i wrong.
thank you for your help and sorry for my bad english.
Here is my code:
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define ONE_WIRE_BUS 2 //ds18b20 module attach to pin2
OneWire oneWire(ONE_WIRE_BUS);// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "****";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "WLAN-NSTZNK 2,4GHz";
char pass[] = "****";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void pressure()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, (analogRead(A0)-102)*13.7895/819);
Serial.print("Press: ");
Serial.println(analogRead(A0));
}
void getTemp()
{
sensors.requestTemperatures(); // Send the command to get temperatures
Blynk.virtualWrite(V6, sensors.getTempCByIndex(0));
Serial.print("Temp: ");
Serial.println(sensors.getTempCByIndex(0));
}
void wlansignal()
{
long rssi = WiFi.RSSI();
Blynk.virtualWrite(V7, WiFi.RSSI());
Serial.print("RSSI:");
Serial.println(rssi);
}
void setup()
{
// Debug console
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
sensors.begin(); // initialize the bus
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);
// Setup a function to be called every second
timer.setInterval(2000L, pressure);
timer.setInterval(10000L, getTemp);
timer.setInterval(4000L, wlansignal);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
And the serial monitor:
[122]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on Arduino Mega
[713] Connecting to WLAN-NSTZNK 2,4GHz
[3766] WIFI CONNECTED
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[8922] +CIFSR:STAIP,"192.168.2.57"
+CIFSR:STAMAC,"38:2b:78:04:75:50"
[8929] Connected to WiFi
[19408] Ready (ping: 13ms).
Press: 101
Press: 102
RSSI:0
Press: 116
Press: 101
Temp: 19.31
RSSI:0
best regards!