Working on the ESP<-> Arduino communication now.
This is the minimum required hardware to run the ESP and the ATMega using a 5V power supply (aka what I get when I connect this to the relais/box I already have built):
![[Image: 2wwGaq4.jpg]](https://i.imgur.com/2wwGaq4.jpg)
![[Image: VPxBvMc.png]](https://i.imgur.com/VPxBvMc.png)
A pretty simple design. On the right 5V in via USB, converted to 3.3V. On the left the AT which only requires VCC, GND and the two connectors (yellow/green) for the serial signal, and in the middle the ESP.
The AT328p required some changes using a program called avrdude to run. There are three bytes on the chip which regulate several settings, e.g. at which speed it should run, if it should use an internal oscilator to generate the frequency and some more. There are pages dedicated to this topic. What I did was to switch the chip to the internal 8MHz osci, plus I had to disable the brown out detector so it wouldn't reset all the time instead of running at 3.3V. The low fuse byte was changed to E2, the extened one to 07, the high one I didn't touch.
To program such an AT, the easiest way is to buy an ATMega Uno and a programming shield. Upload a special script/program to the Uno (included in the installation), then change the target chip for programming to Arduino mini pro/3.3V, 8MHz and upload scripts via the "Upload using programmer" function after plugging the barebone AT328p into the blue ZIF socket.
![[Image: r7sM4Y0.jpg]](https://i.imgur.com/r7sM4Y0.jpg)
The ESP can run in two modes. The default mode is the AT mode where it works just like a good old serial modem, connected to the serial port of a computer. To change this behaviour, three pins need to pulled to high/low using 10kohm resistors. Then the ESP runs whatever you upload to it instead of accepting AT commands. The problem now is: with the 3 resistors in place you can only run programs, but not upload them. Instead of adding more hardware, I decided to replace the ESP-07s with a pin compatible ESP-12e which doesn't have the external antenna, but offers a better way to solder some wires to it:
![[Image: u94XmCF.jpg]](https://i.imgur.com/u94XmCF.jpg)
For (re)programming, I plug the ESP into the ESP shield, for running/testing, I just connect it to the breadboard using the wires I soldered to it.
Now I am hunting a strange bug/problem related to the serial connection. The webserver becomes unresponsive for a second or two after a refresh and doesn't accept a new connection.
This is the minimum required hardware to run the ESP and the ATMega using a 5V power supply (aka what I get when I connect this to the relais/box I already have built):
![[Image: 2wwGaq4.jpg]](https://i.imgur.com/2wwGaq4.jpg)
![[Image: VPxBvMc.png]](https://i.imgur.com/VPxBvMc.png)
A pretty simple design. On the right 5V in via USB, converted to 3.3V. On the left the AT which only requires VCC, GND and the two connectors (yellow/green) for the serial signal, and in the middle the ESP.
The AT328p required some changes using a program called avrdude to run. There are three bytes on the chip which regulate several settings, e.g. at which speed it should run, if it should use an internal oscilator to generate the frequency and some more. There are pages dedicated to this topic. What I did was to switch the chip to the internal 8MHz osci, plus I had to disable the brown out detector so it wouldn't reset all the time instead of running at 3.3V. The low fuse byte was changed to E2, the extened one to 07, the high one I didn't touch.
To program such an AT, the easiest way is to buy an ATMega Uno and a programming shield. Upload a special script/program to the Uno (included in the installation), then change the target chip for programming to Arduino mini pro/3.3V, 8MHz and upload scripts via the "Upload using programmer" function after plugging the barebone AT328p into the blue ZIF socket.
![[Image: r7sM4Y0.jpg]](https://i.imgur.com/r7sM4Y0.jpg)
The ESP can run in two modes. The default mode is the AT mode where it works just like a good old serial modem, connected to the serial port of a computer. To change this behaviour, three pins need to pulled to high/low using 10kohm resistors. Then the ESP runs whatever you upload to it instead of accepting AT commands. The problem now is: with the 3 resistors in place you can only run programs, but not upload them. Instead of adding more hardware, I decided to replace the ESP-07s with a pin compatible ESP-12e which doesn't have the external antenna, but offers a better way to solder some wires to it:
![[Image: u94XmCF.jpg]](https://i.imgur.com/u94XmCF.jpg)
For (re)programming, I plug the ESP into the ESP shield, for running/testing, I just connect it to the breadboard using the wires I soldered to it.
Now I am hunting a strange bug/problem related to the serial connection. The webserver becomes unresponsive for a second or two after a refresh and doesn't accept a new connection.