Good day all, I'm currently working on a home automation project. The basics is that the esp-01 receives data from an android app via HTTP, extracts a number from the string and transmits it to an ATtiny85 based receiver. The first part of the code seems to work but, the receiver isn't because i'm having issues findng RF libraries that will function on both chips. Please i need your help. I have tried RCSwitch and TinyHead. Attached is my transmitter code.
Transmitter
/* Create a WiFi access point and provide a web server on it. */
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
const int transmit_pin = 2;
/* Set these to your desired credentials. */
const char *ssid = "username";
const char *password = "password";
uint16_t code;
String response_data = "";
ESP8266WebServer server(80);
/* Just a little test message. Go to http://192.168.4.1 in a web browser
* connected to this access point to see it.
*/
void root()
{
send_response("<h1>Welcome Home</h1>");
}
void check_connection()
{
send_response("<h1>000</h1>");
}
void entrance_light_ON()
{
response_data = "<h1>101</h1>";
//code = load_char(response_data.substring(4,7));
code = response_data.substring(4,7).toInt();
sendCode(code);
send_response(response_data);
}
void entrance_light_OFF()
{
response_data = "<h1>100</h1>";
//code = load_char(response_data.substring(4,7));
code = response_data.substring(4,7).toInt();
sendCode(code);
send_response(response_data);
}
void send_response(String data)
{
server.send(200, "text/html", data);
}
void sendCode(uint16_t code)
{
Serial.print("Sent code = ");
Serial.println(code);
sendMultiple(code,10);
Serial.println("Data Sent");
}
void sendMultiple(uint16_t msg, int no)
{
if(no >= 1)
{
for(int i = 0; i < no; i++)
{
mySwitch.send(msg,24);
delay(100);
}
}
}
void setup()
{
Serial.begin(115200);
delay(1000);
//setup transmitter
mySwitch.enableTransmit(transmit_pin);
Serial.println();
Serial.print("Configuring access point...\n");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", root);
server.on("/L_000",check_connection);
//ON commands
server.on("/L_101",entrance_light_ON);
//OFF commands
server.on("/L_100",entrance_light_OFF);
server.begin();
Serial.println("HTTP server started");
}
void loop()
{
server.handleClient();
}