I haven't put the firmware on Github for the ESP8266 in the Sonoff device, because it is just slapped together to get the project started. When I really start to work on the full featured ESP8266, I will put it up on Github, but for now, here is the firmware for reference:
#include <user_config.h>
#include <SmingCore/SmingCore.h>
#define RELAY_PIN 12 // GPIO12
Timer procTimer;
bool state = true;
void onSerialDataCallback(Stream& stream, char c, unsigned short charCount)
{
Serial.print("0x");
Serial.print(String(c,HEX));
Serial.print(" ");
Serial.print(charCount);
while(stream.available())
{
char cmd=stream.read();
if(cmd == 'N')
digitalWrite(RELAY_PIN,true);
if(cmd == 'F')
digitalWrite(RELAY_PIN,false);
}
}
void init()
{
Serial.begin(115200);
pinMode(RELAY_PIN, OUTPUT);
Serial.setCallback(onSerialDataCallback,true);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.