Smart lamp base REDMOND - add to the smart home
In this review, we will talk about the smart base of the REDMOND brand - SkySocket 202S. An article about the circuitry of this socle caught my eye, after reading I noticed that the brain from this device is a chip from the company Nordic Semiconductor 51 series (nRF51822).
My main hobby at the moment is building a smart home. I am slowly building a radio network from devices using the MySensors protocol. If briefly about this protocol, then perhaps we can say that this is a very simple and convenient protocol based on which in one hour in the Ardunno IDE you can assemble a couple of devices from arduino modules and launch your first radio sensor network. Recently, I have been making devices for my MySensors network on the nRF51822 and nRF52832 radio modules, which is why I noticed this base.
Having bought it in an online store (for quite a bit of money in the region of 700 rubles) and having examined it, I saw that 4 contacts for programming are conveniently displayed on the board. Without thinking twice, I took out my Chinese ST-LINK programmer and multimeter and took up the wiring of the board to outline the device diagram. In the process of drawing up the device diagram, it became clear that only 4 pins are used on the module, a button on pin p0.27, a bus on pin p0.26, a triac relay on pin p0.16 and a zero detector circuit on pin p0.00. For 20 minutes, I sketched the program in the Arduino IDE (it was very simple and fast to write with MySensors above), connected the ST-LINK programmer and, lo and behold, compiling, downloading, the programmer stopped flashing and turned green, which means the firmware was loaded. Immediately opened the browser, opened the Majordomo, MySensors module already displayed a new device on the network - REDMOND nRF51 1.0. It remains only to create objects, make buttons, which I did immediately. So, after an hour and a half, I already controlled the light bulb in this base according to the MySensors protocol.
Telegram chat of our mysensors community, where everyone will tell and help - https://t.me/mysensors_rus
Arduino code (it seems the backlight is not supported):
#define BUTTON_PIN 27
#define BIZZER_PIN 26
#define ZERO_CROSS_PIN 0
#define RELAY_PIN 16
boolean iswitch = 1;
boolean flag_button = 0;
static uint32_t previousMillis;
//#define MY_DEBUG
#define MY_DISABLED_SERIAL
#define MY_RADIO_NRF5_ESB
//#define MY_PASSIVE_NODE
#define MY_NODE_ID 200
#define MY_PARENT_NODE_ID 0
#define MY_PARENT_NODE_IS_STATIC
//#define MY_TRANSPORT_UPLINK_CHECK_DISABLED
#define MY_REPEATER_FEATURE
#define RELAY_ID 1
#include
MyMessage lMsg(RELAY_ID, V_STATUS);
void preHwInit() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BIZZER_PIN, OUTPUT);
pinMode(ZERO_CROSS_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
}
void before()
{
//delay(2000);
while (digitalRead(ZERO_CROSS_PIN) != 0) {
//digitalWrite(RELAY_PIN, iswitch);
//wait(200);
}
digitalWrite(RELAY_PIN, iswitch);
}
void presentation()
{
sendSketchInfo("REDMOND nRF51", "1.0");
wait(100);
present(RELAY_ID, S_BINARY, "LIGHT SWITCH");
}
void setup()
{
myTone(800, 50);
delay(70);
myTone(1500, 150);
delay(30);
wait(500);
send(lMsg.set(iswitch));
wait(100);
}
void loop()
{
if (digitalRead(BUTTON_PIN) == LOW && flag_button == 0) {
flag_button = 1;
previousMillis = millis();
wait(20);
myTone(800, 50);
delay(100);
//myTone(1500, 200);
//delay(30);
}
if (digitalRead(BUTTON_PIN) == LOW && flag_button == 1) {
}
if (digitalRead(BUTTON_PIN) == HIGH && flag_button == 1) {
if ((millis() - previousMillis > 0) && (millis() - previousMillis <= 3000)) {
flag_button = 0;
myTone(800, 50);
delay(70);
myTone(1500, 150);
delay(30);
iswitch = !iswitch;
while (digitalRead(ZERO_CROSS_PIN) != 0) {
//iswitch = !iswitch;
}
digitalWrite(RELAY_PIN, iswitch);
myTone(1500, 150);
delay(30);
wait(100);
send(lMsg.set(iswitch));
wait(300);
}
if (millis() - previousMillis > 3000)
{
flag_button = 0;
wait(100);
}
}
}
void receive(const MyMessage & message) {
if (message.type == V_STATUS) {
if (message.sensor == RELAY_ID) {
if (mGetCommand(message) == 1) {
if (message.isAck()) {
//AckG = 1;
} else {
//
iswitch = !iswitch;
while (digitalRead(ZERO_CROSS_PIN) != 0) {
//iswitch = !iswitch;
}
digitalWrite(RELAY_PIN, iswitch);
wait(200);
myTone(800, 50);
delay(70);
myTone(1500, 150);
delay(30);
wait(100);
send(lMsg.set(iswitch));
wait(1000);
}
}
if (mGetCommand(message) == 2) {
}
}
}
/*
if (message.isAck()) {
(message.sensor == LIGHT_SENS_ID) {
}
(message.sensor == TEMP_INT_ID) {
}
}
*/
}
void myTone(uint32_t j, uint32_t k) {
j = 500000 / j;
k += millis();
while (k > millis()) {
digitalWrite(BIZZER_PIN, HIGH); delayMicroseconds(j);
digitalWrite(BIZZER_PIN, LOW ); delayMicroseconds(j);
}
}
void playSound() {
}