/*
AT Firmware simulation example
Use the serial monitor to interface with the AT firmware. For instance, to scan for WiFi:
AT+CWMODE=1
AT+CWLAP
Connect to WiFi:
AT+CWJAP="Wokwi-GUEST",
Show the current IP address:
AT+CIFSR
Show firmware version
AT+GMR
To show list list of available commands:
AT+CMD?
*/
int incomingByte = 0;
void SendATCmd(String str, int dly)
{
Serial1.println(str);
for(int i= 0; i < dly; i++)
{
while(Serial1.available() > 0)
{
incomingByte = Serial1.read();
Serial.write(incomingByte);
}
delay(1);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Welcome to the AT Playground!");
Serial.println("-----------------------------");
Serial1.begin(115200);
Serial.println("Start Serial 1");
delay(1000);
Serial.println("Send AT commands");
SendATCmd("AT+CWMODE=1", 500);
SendATCmd("AT+CWLAP", 2000);
SendATCmd("AT+CWJAP=\"Wokwi-GUEST\",", 10000);
SendATCmd("AT+CIFSR", 2000);
// send POST request
// .\curl -v -d 'api_key=tPmAT5Ab3j7F9&sensor=curlBME&location=G28 Office&value1=19.77&value2=39.95&value3=1025.56'
// http://v-p.bnr.la/~micros/insert.php
// results: http://v-p.bnr.la/~micros/eds_data_display.php
// AT+HTTPCLIENT=3,0,"http://v-p.bnr.la/~micros/insert.php",,,1,
// "api_key=tPmAT5Ab3j7F9&sensor=DHT11&location=Wokwi&value1=19.77&value2=39.95&value3=1025.56"
SendATCmd("AT+HTTPCLIENT=3,0,\"http://v-p.bnr.la/~micros/insert.php\",,,1,"
"\"api_key=tPmAT5Ab3j7F9&sensor=DHT11&location=Wokwi&value1=19.77&value2=39.95&value3=1025.56\"",
1000);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial1.available() > 0)
{
incomingByte = Serial1.read();
Serial.write(incomingByte);
}
}