Generating 1.5K Hz square wave on Photon2

I am using 4 PWM signals at 60 HZ. On Photon 2. How can I generate 1.5KZ squire wave signal on Photon 2

The tone() function can be used for this on all devices.

The caveat for Gen 4 (Photon 2, P2, M-SoM, RTL872x) is that there is a single timer used for all PWM outputs, so you can only output a single frequency at a time.

Thanks for your advice Sir. Since I need a continues 1.5KH signal at the same time I have 4 PWM running at 60 HZ on A2,A5,MOSI MISO pins and 1.5Kz on D8. I will not be able to use the tone function for D8

I will use a 555 timer chip to my board which will add an additional costs to my product. This is what I was trying to possibly avoid
Thanks again Sir

It is not possible to generate more than one frequency at a time using tone() on RTL872x. You will need to use external hardware.

60 Hz is probably low enough to generate by brute force. You could try setting up a worker thread and using pinSetFast, pinResetFast to change the state 120 times per second. The thread will be better than doing it from loop, but the signal may still have some jitter.

Since you have so many PWMs, I would also consider using a PWM generator controlled by I2C.

Thank you Sir. How can I use a PWM generator controlled by I2C.
Would you guide me through it please. Is this your way of generating 1.5KZ continues signal?

Thanks Sir.

Hi Kazem, I never used one, but a quick search on Adafruit gave me this:

Tutorial on how to use it:

1 Like

Gentlemen, I am getting an ABS box with an aluminum bottom plate. Would this plate weaken Wi-Fi signal?

The bottom is probably the best-case scenario for a metal plate, assuming that the Wi-Fi signal doesn't come from that direction. If you have some spacing between the device and the plate, at least 1 cm, that is also helpful. If you don't have sufficient signal the Photon 2 can be used with an external antenna.

Thanks Sir. You mean after I install a bottom plate under the CPU with 1Cm spacing and the signal may weaken or (Degraded ) then I need to use an external antenna ? I am trying not to have to add any more costs to the finished product. Looks like there is no definite answer to metal bottom plate effecting Wi-Fi signal. All 120 Volt AC Wi-Fi switches are mounted inside a grounded meatal box. How do they manage that