📶

Wi-Fi Connection [Serial]

💡
NodeMCU are available and will be used for Wi-Fi connectivity and serial communication will be used for data transfer

Connection [Serial]:

NodeMCU
Spresense Extension Board
GND
GND
Vin
Vout
RX
TX
TX
RX

Code Testing

Spresense:
#include <SoftwareSerial.h> #include <ArduinoJson.h> SoftwareSerial nodemcu(0, 1); // RX, TX void setup() { Serial.begin(9600); nodemcu.begin(9600); delay(1000); serial.println("Test Started"); } Void loop() { // Start JSON data StaticJsonBuffer<1000> jsonBuffer; JsonObject& data = jsonBuffer.createObject(); // Add values to JSON data data["test1"] = "ok"; data["test2"] = "working"; // Send JSON data to nodeMCU data.printTo(nodemcu); jsonBuffer.clear(); delay(2000); }
NodeMCU:
#include <SoftwareSerial.h> #include <ArduinoJson.h> SoftwareSerial nodemcu(D6, D5); // RX, TX void setup() { Serial.begin(9600); nodemcu.begin(9600); while (!Serial); continue; } void loop() { StaticJsonBuffer<1000> jsonBuffer; JsonObject& data = jsonBuffer.parseObject(nodemcu); if (data == JsonObject::invalid()) { Serial.println("Invalid JSON"); jsonBuffer.clear(); return; } serial.println("JSON Object Recieved:"); String first = data["test1"]; serial.println(first); String second = data["test2"]; serial.println(second); Serial.println("-----------------------------------------"); }