I am using the code and app of this link Simple 4 relay irrigation scheduler but I have doubts about how to flash the code inside my sonoff. I copy the code, I input my token, my ssid and password but I also have static ip in my router, then I don’t know how to fix a static it in the code.
I think you need to explain this bit in more detail.
Do you mean you have a static public IP address, or that you want the Sonoff to allows use the same IP within your home network?
If you router is using DHCP to hand-out IP addresses to devices on your network then the easiest solution is to allocated a fixed IP address to your Sonoff in your router. When the Sonoff requests an IP address from the router’s DHCP server it will then be given the one you’ve specified.
Thks for your reply. I have a network with static ip. I do that in each device less in one laptop that I used the MAC address to fic a static ip from the router. The problem is I cannot find the MAC address for my sonoff.
Also I want to know if I can use 5Ghz network for my iPhone and to connect sonoff to 2.4 ghz the sonoff.
You should be able to Google ways to read MAC addresses from various ESP based devices.
You should be also able to isolate your routers connected DHCP devices and figure out which one is your Sonoff.
But if you can’t do that, then as already shown, you many need to load in another example sketch, like what I provided or make something up on your own… it need not be Blynk related, but then will need a WiFi library… and read the devices MAC address with the listed command WiFi.macAddress()
I copy your code on ATOM and I added below lines to connect as static IP.
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “my token”;
// Your WiFi credentials.
// Set password to “” for open networks.
char ssid[] = “my ssid”;
char pass[] = “my password”;
IPAddress server_ip (XXXXXX);
// Mac address should be different for each device in your LAN
// byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress sonoff_ip ( x, x, x, x);
IPAddress dns_ip ( 8, 8, 8, 8);
IPAddress gateway_ip ( x, x, x, x);
IPAddress subnet_mask (255, 255, 255, 0);
First of all, you need to go back and edit your last post (using the pencil icon at the bottom) and format your code correctly. You’ve used “quote” and “unquote” where you should be using triple backticks - like this:
Secondly, you’re missing a comma between the third and fourth "x"s here:
IPAddress gateway_ip ( x, x, x x);
Thirdly, this is illegal:
IPAddress server_ip (blynk-cloud.com);
When you’ve corrected the formatting of your code I’ll tell you what you should use instead.
It was still wrong, you used apostrophes instead of backticks. I’ve fixed if for you now, but you need to figure it out for the future.
You need to replace:
IPAddress server_ip (blynk-cloud.com);
with
const char server_ip [] = "blynk-cloud.com";
If you’re a rookie then I’d suggest that you drop the ATOM IDE and go for the Arduino IDE instead. It’s what the vast majority of community members use you’ll find it much easier to get community support that way.
I’m still confused about why you don’t just set-up your router to have a small range of DHCP addresses and get up and running that way.
The reason to use static ip’s is because I have all my devices with static ip including my NAS.
I bought a sonoff ch4 pro in order to do a irrigation system. I already have it ready to flash new firmware which should be in BIN extension.
I copy one of the above projects and I added just the ip lines to make it static. I used Atom to do that. Now once finished I think I have to compile it in order to use it to flash the sonoff, but I am doing something wrong or I missed some step.
I am trying to find it in google but I was not able to find all steps to compile above text.
If someone can support me or can tell me where to find more info I will appreciate.
Hi Pete. Finally I did. I used Arduino IDE with one sketch posted here. I selected my board ESP8266 and I compiled. Tomorrow I will try to flash my sonoff and I will test it.
Thks a lot, I was try Atom when sketch is wonderful and easier.
Hello. I don’t know the reason but my sonoff CH4 Pro is well flashed at 100% but when I try to star it, it do a knock noise and blue light doent star. Maybe I did something wrong.
I am thinking to buy a Arduino board and some relays. Any special brand/model to work with this sketch?
Did you flash it in the correct mode?
Is it connecting to your wi-fi and Blynk server?
What serial output are you getting?
If you’re going for different hardware (I’d stick with getting the Sonoff working if I were you) then before you rush out and buy an Arduino you should read this:
Did you read the link I gave you?
Do you realise that the product you’re thinking of buying has no wired or wireless internet connection capability as it stands?
Vyou do t have to “trick” the Sonoff, you have to replace the existing firmware with your own firmware, by uploading a new sketch to it. This is exactly the same as you would have to do with any other device you chose to use.
If you’re not happy to answer questions on what flash settings you used, whether the device is connecting to Blynk and what serial output you’re getting then I’ll step back and let you do your own thing.
Hi Pete. I read your link. Interesting. The problem of sonoff is that you hace to weld some cable in the chip and I don’t know I did property. Arduino IDE confirm 100% flashing but when I connect sonoff is not doing anything.
This is the reason why I am thing to buy an Arduino board with WiFi + relays in otprder to connect my garden irrigation Solenoid and control it from my mobile.
I think I replied all your question.