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.
You shouldn’t need to be soldering anything to the chip, just soldering-in the FTDI headers and finding the correct location to pull GPIO0 to earth while you’re powering it up.
If you hadn’t done it correctly from a hardware point of view then it wouldn’t flash to 100%.
What’s more likely is that you’ve chosen the wrong settings in the Arduino IDE.
I’ve asked twice, but I don’t see any info about the flash settings you used in the Arduino IDE, whether it’s connecting to Blynk or what output you’re getting in the Arduino IDE serial monitor, but don’t worry, I wont bother asking again.
In which case you’ll need to modify the sketch, and use SoftwareSerial to connect your Arduino and Wi-Fi modem.
Finally I am not able to flash sonoff. Something happened at hardware level because now I cannot connect it again to my computer. No lights on. I think it died.
Then now I will go for Arduino which is easier to flash. I read your link about boards and due to my inexperience soldering, i am thinking to buy following board. What do you think?
My idea is to use the sketch from this link
From Hagay or Arizona users. Hagay used sonoff then I supposed I will need to change something in the sketch.
I will read more to make less questions.
Thks a lot for your support and sorry for bordering you.