Hello
tried without multiplexing, also tried multiplexing and specifying the connection number, but no way, it always timeouts
I’ve followed the wiki and flashed espduino to ESP8266, using NodeMCUFlasher utility under windows, and flashing the two offsets (0x00000 and 0x40000), it gave green light in the end
I then flashed thingspeak.ino using a DHT11 sensor connected to pin7.
Here is the code:
/**
* \file
* ESP8266 RESTful Bridge example
* \author
* Tuan PM <tuanpm@live.com>
*/
#include <espduino.h>
#include <rest.h>
#include <dht.h>
#define PIN_ENABLE_ESP 13
#define SSID "ssssssss"
#define PASS "pppppppp"
dht DHT;
ESP esp(&Serial1, &Serial, 4);
REST rest(&esp);
boolean wifiConnected = false;
void wifiCb(void* response)
{
uint32_t status;
RESPONSE res(response);
if(res.getArgc() == 1) {
res.popArgs((uint8_t*)&status, 4);
if(status == STATION_GOT_IP) {
Serial.println("WIFI CONNECTED");
wifiConnected = true;
} else {
wifiConnected = false;
}
}
}
void setup() {
Serial1.begin(19200);
Serial.begin(19200);
esp.enable();
delay(500);
esp.reset();
delay(500);
while(!esp.ready());
Serial.println("ARDUINO: setup rest client");
if(!rest.begin("api.thingspeak.com/channels/69522")) {
Serial.println("ARDUINO: failed to setup rest client");
while(1);
}
/*setup wifi*/
Serial.println("ARDUINO: setup wifi");
esp.wifiCb.attach(&wifiCb);
esp.wifiConnect(SSID, PASS);
Serial.println("ARDUINO: system started");
}
void loop() {
char response[266];
esp.process();
if(wifiConnected) {
int chk = DHT.read11(7);
if(chk == DHTLIB_OK){
char buff[64];
char str_hum[6], str_temp[6];
dtostrf(DHT.humidity, 4, 2, str_hum);
dtostrf(DHT.temperature, 4, 2, str_temp);
sprintf(buff, "/update?api_key=Y01VVB4B2E6MP6W9&field1=%s&field2=%s", str_hum, str_temp);
Serial.println(buff);
rest.get((const char*)buff);
Serial.println("ARDUINO: send get");
if(rest.getResponse(response, 266) == HTTP_STATUS_OK){
Serial.println("ARDUINO: GET successful");
Serial.println(response);
}
delay(30000);
} else {
Serial.print("error,\r\n");
}
}
}
The code is the same as the example, I only updated SSID/PWD for wifi, channel for thingspeak and API key (this is just a test so I left them in the code)
unfortunately nothing works, thingspeak is not updated and when I open a serial monitor nothing shows up (baud is set properly at 19200), it’s all blank
the micro still works because if I flash a simple “hello world” sketch it works
please help because I’m stuck