Chapter 10. Networking
Due to the small size of the devices upon which MicroPython runs, there is no room to add an ethernet socket. As a result, those devices that include capabilities for inter-device communication do so wirelessly.1
There is something strangely satisfying about interacting at a distance: it feels like magic. However, there’s something much better than magic going on: physics! How such communication works is fascinating, and two types of communication will be covered in this chapter: infrared (on the Circuit Playground Express) and radio (on the micro:bit- and ESP8266/32-based devices).
Infrared (IR) communication is most commonly associated with television remote controls: slabs of buttons to be poked and pressed while pointing the device at the TV. Infrared works well over a short distance so long as there’s a line of sight between the transmitter and receiver (hence the requirement that you point the remote at your TV). We can’t see infrared light because its wave length is just below that of visible light.2 There are many sources of infrared light in our environment: the sun, light bulbs, candles, and even our own bodies (our bodies radiate most of their heat in the infrared spectrum). To overcome the potential for interference from such ambient sources of infrared light, when sending a signal it is common to modulate it. In this instance, modulation means the signal is sent at a pre-agreed frequency, the most common being 38 kHz (although other frequencies ...
Get Programming with MicroPython now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.