Jump to content

I'm still fairly new to Arduino's or arduino-like products. So I figured to ask this question here, as googling it hasn't given me an answer I could work with.

 

I'm currently making a SmartHome system, that currently has a temperature sensor, a central heater controller and a web-app to control it.

Looking forward, I want to make this system a bit more advanced. So I'm currently adding my electricity meter and gas meter.

So I hooked up a ESP8266 ESP12 (NodeMCU 0.9) to the P1 port on my KFM5 Kaifa Meter.

It works completely fine, and gives the results I'm searching for. Also it manages to send it to api.example.domain.ext (insert "real domain" here)

But this requires the ESP to have a valid internet connection. So currently the signal goes through my router, to my modem, then back to the router and then towards the server that hosts the database and webserver.

My thermostat is working on a raspberry pi, since it's linux I can simply can edit the hosts-file equivalent to point api.example.domain.ext to a local IP for example 10.0.2.2

I've done this, so the thermostat can have more control on the GUI then anything that is connected outside the network. (Thermostat has a touch screen display)

Also this gives a nice side effect that, if my internet connection is down, the thermostat would still work.

 

Since the ESP12 isn't linux based, and uses C/C++ I have no clue how to get somewhat the same results.

As it is able to resolve api.example.domain.ext, it should be possible right?

Any idea how?

Main RIG: i7 4770k ~ 4.8Ghz | Intel HD Onboard (enough for my LoL gaming) | Samsung 960 Pro 256GB NVMe | 32GB (4x 8GB) Kingston Savage 2133Mhz DDR3 | MSI Z97 Gaming 7 | ThermalTake FrioOCK | MS-Tech (puke) 700W | Windows 10 64Bit

Mining RIG: AMD A6-9500 | ASRock AB350 Pro | 4GB DDR4 | 500GB 2.5 Inch HDD | 2x MSI AERO GTX 1060 6GB (Core/Memory/TDP/Avg Temp +160/+800/120%/45c) | 1x Asus Strix GTX 970 (+195/+400/125%/55c) | 1x KFA2 GTX 960 (+220/+500/120%/70c) | Corsair GS800 800W | HP HSTNS-PD05 1000W | (Modded) Inter-Tech IPC 4U-4129-N Rackmount Case

Guest RIG: FX6300 | AMD HD7870 | Kingston HyperX 128GB SSD | 16GB (2x 8GB) G.Skill Ripjaws 1600Mhz DDR3 | Some ASRock 970 Mobo | Stock Heatsink | some left over PSU  | Windows 10 64Bit

VM Server: HP Proliant DL160 G6 | 2x Intel Xeon E5620 @ 2.4Ghz 4c/8t (8c/16t total) | 16GB (8x 2GB) HP 1066Mhz ECC DDR3 | 2x Western Digital Black 250GB HDD | VMWare ESXI

Storage Node: 2x Intel Xeon E5520 @ 2.27Ghz 4c/8t (8c/16t total) | Intel ServerBoard S5500HCV | 36GB (9x 4GB) 1333Mhz ECC DDR3 | 3x Seagate 2TB 7200RPM | 4x Western Digital Caviar Green 2TB

Link to comment
https://linustechtips.com/topic/803657-esp8266-esp12-hosts-equivalent/
Share on other sites

Link to post
Share on other sites

Personally i do not know if its possible to change that on an esp, but you could change the domain to the ip adres and maybe have that vhost as default server in apache.

 

Or you could change the dns on the esp in your script to a proxy dns on your raspberry pi, so that it stil goes to api.*.*.com but its resolved to your Raspberry  

Link to post
Share on other sites

Just now, djneo said:

Personally i do not know if its possible to change that on an esp, but you could change the domain to the ip adres and maybe have that vhost as default server in apache.

 

Or you could change the dns on the esp in your script to a proxy dns on your raspberry pi, so that it stil goes to api.*.*.com but its resolved to your Raspberry  

The webserver/api isn't hosted on a raspberry pi, but on a Plesk powered Ubuntu server. It also hosts a DNS server, but that controls the actual domain for real. Not for local use, if you get what I mean. I could force the arduino to use a different DNS server. But I kinda want to hardcode this.

Main RIG: i7 4770k ~ 4.8Ghz | Intel HD Onboard (enough for my LoL gaming) | Samsung 960 Pro 256GB NVMe | 32GB (4x 8GB) Kingston Savage 2133Mhz DDR3 | MSI Z97 Gaming 7 | ThermalTake FrioOCK | MS-Tech (puke) 700W | Windows 10 64Bit

Mining RIG: AMD A6-9500 | ASRock AB350 Pro | 4GB DDR4 | 500GB 2.5 Inch HDD | 2x MSI AERO GTX 1060 6GB (Core/Memory/TDP/Avg Temp +160/+800/120%/45c) | 1x Asus Strix GTX 970 (+195/+400/125%/55c) | 1x KFA2 GTX 960 (+220/+500/120%/70c) | Corsair GS800 800W | HP HSTNS-PD05 1000W | (Modded) Inter-Tech IPC 4U-4129-N Rackmount Case

Guest RIG: FX6300 | AMD HD7870 | Kingston HyperX 128GB SSD | 16GB (2x 8GB) G.Skill Ripjaws 1600Mhz DDR3 | Some ASRock 970 Mobo | Stock Heatsink | some left over PSU  | Windows 10 64Bit

VM Server: HP Proliant DL160 G6 | 2x Intel Xeon E5620 @ 2.4Ghz 4c/8t (8c/16t total) | 16GB (8x 2GB) HP 1066Mhz ECC DDR3 | 2x Western Digital Black 250GB HDD | VMWare ESXI

Storage Node: 2x Intel Xeon E5520 @ 2.27Ghz 4c/8t (8c/16t total) | Intel ServerBoard S5500HCV | 36GB (9x 4GB) 1333Mhz ECC DDR3 | 3x Seagate 2TB 7200RPM | 4x Western Digital Caviar Green 2TB

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×