Monday, May 2, 2016

Getting started with the ESP8266, NodeMCU and Wemos D1 Mini

After a long, work induced, hiatus away from electronics I have started up again with the ESP8266 serial of WiFi connected microprocessors. In the past I had been experimenting with sensor platforms based on an Arduino UNO and Ethernet shield. These were fine as far as they went but being tied to a wired ethernet cable made them less that portable.

I made the decision to switch platforms after trying WiFi solutions based on the CC3000 chipset tied to the Arduino UNO and being very disappointed by their reliability. I noticed that the Arduino development environment had started to support the ESP8266 chipset and initial reports seemed to indicate they ran for long periods of time without issues.

With more and more 3.3 Volts parts being made available on breakout boards, it also seemed like the right time to make the shift to a 3.3V microcontroller.

Initially I started with the NodeMCU development board which ran a Lua interpreter. This appeared to work fairly well but I am used to the Arduino development and programming with its implementation of C so I switched to the Arduino IDE. In addition there are many more hardware support libraries available in the Arduino environment, the vast majority of which run without modification of the ESP8266. The NodeMCU boards fit neatly into breadboards and are well suited for experimentation.

Fortunately I have side-stepped any issues with drivers for the on-board serial to USB chips by using Linux as a development environment. Unfortunately I can't offer any suggestions for other operating systems such as Windows or Mac OS/X.

My first project was a temperature and humidity sensor using the DHT11 sensor. Using the WiFi connection, through my home router, the sensor information was sent out to ThingSpeak every 10 minutes. After sending the MCU was put into deep sleep mode until another ten minutes had passed, at which point the MCU was reset and the cycle started again. The code I used for this is available for download here: thingspeak_data-logger.ino (Arduino 1.6.7)

Since I ultimately wanted to run the sensor from a rechargeable battery I needed to be able to read the voltage being supplied to the ESP8266. This function is built into the ESP8266 but it took some time to figure out the right incantation to get it to work. For the record this is documented below:

In the initial header of your project you need to specify "ADC_MODE(ADC_VCC);" to enable analog 0 (A0) to read VCC.
Once that is complete, in the main body of the code, you can read VCC using "float vcc = ESP.getVcc();" to read the current VCC*1024. Dividing by 1024 should yield a figure representing VCC in volts.

Using the NodeMCU with deepsleep I was able to power the sensor from a USB power-pack for approximately 20 days before the powerpack shutdown to protect the Lithium-ion batteries.

Later, cruising around the online Chinese supplyhouse AliExpress, I discovered a smaller form factor version of the ESP8266 breakout board that had a healthy collection of shields containing most of the electronics I was interested in. The Wemos D1 Mini is about the size of a postage stamp but still contains all the support electronics including serial-to-USB and 5V to 3.3V regulator.

When using the WiFi sensor code on the Wemos D1 Mini I have been able to run for at 15 days on the same USB battery pack before it showed any sign of discharging (three out of four battery level lights lit) so I'm assuming that the D1 Mini draws much less power in deep sleep and is therefore a better choice for battery powered projects.

For my own reference as much as anything I made a list of the currently available D1 Mini shields and the pins they use:

Shield Name Device Type Pin Used Pin Definition
DHT Shield DHT11 Pin D4 Data Out
DHT ProShield DHT22 Pin D4 Data Out
OLED Shield OLED using SSD1306 driver Pin D1, D2 SCL, SDA
1-Button Shield Momentary push button Pin D3 Button
Relay Shield V2 5VDC Relay Pin D1 Relay Enable
Micro SD Shield Micro SD adapter Pin D5,D6,D7,D8 CLK,MISO,MOSI,CS
ProtoBoard Shield Proto Area All Pins Proto Area
Dual Base for D1 mini Stack D1, shields side-by-side Pins are duplicated

Important notes: You will need to use a modified library for the OLED display which is available here: SparkFun_Micro_OLED_Arduino_Library If you use the standard Sparkfun library you will not be able to display text.

I have an example of using the OLED shield to display sensor readings from the DHT22 available here: wemos_temp_display.ino (Using DHT sensor library from Adafruit V1.2.3)

I'm hoping that the Wemos D1 Mini and its accompanying shields will enable the quick prototyping of handheld sensor platforms that include wifi connectivity. My next project will involve configuring WiFi SSID, WEP keys and ThingSpeak API keys without having to connect to a computer with the Arduino IDE. Hopefully through the use of a captive portal and switching the ESP8266 into Access Point mode to allow configuration via a tablet of smartphone.

With any luck this information will help you make progress quicker that I did. This hardware is well worth investigating: A full set, including Wemos D1 Mini and all shields, is only going to set you back perhaps $30-$40 if you already have a computer to run the Arduino IDE.

One last thing ... Shipping from China to Texas has typically taken around 20-30 days when ordering from AliExpress. So, order everything you think you might need at once otherwise you are not likely to enjoy the wait while the additional shields you need take, literally, the slow boat from China.

Friday, May 1, 2015

NJIT's New Solar Telescope Unveils the Complex Dynamics of Sunspots' Dark Cores

Groundbreaking images of the Sun captured by scientists at NJIT’s Big Bear Solar Observatory (BBSO) give a first-ever detailed view of the interior structure of umbrae – the dark patches in the center of sunspots – revealing dynamic magnetic fields responsible for the plumes of plasma that emerge as bright dots interrupting their darkness. Their research is being presented this week at the first Triennial Earth-Sun Summit meeting between the American Astronomical Society’s Solar Physics Division and the American Geophysical Union’s Space Physics and Aeronomy section in Indianapolis, Ind.

The high-resolution images, taken through the observatory’s New Solar Telescope (NST), show the atmosphere above the umbrae to be finely structured, consisting of hot plasma intermixed with cool plasma jets as wide as 100 kilometers.
“We would describe these plasma flows as oscillating cool jets piercing the hot atmosphere. Until now, we didn’t know they existed.  While we have known for a long time that sunspots oscillate – moderate resolution telescopes show us dark shadows, or penumbral waves, moving across the umbra toward the edge of a sunspot – we can now begin to understand the underlying dynamics,” said Vasyl Yurchyshyn, a research professor of physics at NJIT and the lead author of two recent journal articles based on the NST observations.

Called spikes, the oscillating jets result from the penetration of magnetic and plasma waves from the Sun’s photosphere – the light-giving layer of its atmosphere – into the abutting chromosphere, which they reach by traveling outward along magnetic tubes that serve as energy conduits.  “This process can be likened to a blowhole at a rocky beach, where relentless onshore waves jet sea water high into the air,” Yurchyshyn said.

Sunspots are formed when strong magnetic fields rise up from the convection zone, a region beneath the photosphere that transfers energy from the interior of the Sun to its surface. At the surface, the magnetic fields concentrate into bundles, which prevent the hot rising plasma from reaching the surface. This energy deficit causes the magnetic bundles to cool down to temperatures about 1,000 degrees lower than their surroundings. They therefore appear darker against the hotter, brighter background.

“But the magnetic field is not a monolith and there are openings in the umbra from which plasma bursts out as lava does from a volcano’s side vents. These plumes create the bright, nearly circular patches we call umbral dots,” Yurchyshyn noted. “Sunspots that are very dark have strong magnetic fields and thus fewer openings.”

Compact groups of fast-changing sunspots create tension in their magnetic systems, which at some point erupt to relieve the stress. It is those eruptions that cause intense “space weather” events in the Earth’s magnetosphere affecting communications, power lines, and navigation systems.

“We had no sense of what happens inside an umbra until we were able to see it in the high-resolution images obtained with the world’s largest solar telescope. These data revealed to us unprecedented details of small-scale dynamics that appear to be similar in nature to what we see in other parts of the Sun,” Yurchyshyn said. “There is growing evidence that these dynamic events are responsible for the heating of coronal loops, seen in ultraviolet images as bright magnetic structures that jet out from the Sun’s surface. This is a solar puzzle we have yet to solve.”

Since it began operating in 2009, Big Bear’s NST has given scientists a closer look at sunspot umbrae, among other solar regions. It has also allowed them to measure the shape of chromospheric spectral lines, enabling scientists to probe solar conditions.

“These measurements tell us about the speed, temperature, and pressure of the plasma elements we are observing, as well as the strength and the direction of the solar magnetic fields,” said Yurchyshyn, who is also a distinguished scholar at the Korea Astronomy and Space Science Institute. “Thus we were able to find that spikes, or oscillating jets, are caused by chromospheric shocks, which are abrupt fluctuations in the magnetic field and plasma that constantly push plasma up along nearly the same magnetic channels.”

The study on umbral spikes was published in the Astrophysical Journal in 2014.

In a second paper published in the Astrophysical Journal in 2015, he is presenting another set of NST observations, taking a closer look at the sunspot oscillations that occur every three minutes and are thought to produce bright umbral flashes - emissions of plasma heated by shock waves.

The NST takes snapshots of the Sun every 10 seconds, which are then strung together as a video to reveal fast-evolving small explosions, plasma flows and the movement of magnetic fields. “We were able to obtain photographs of these flashes of unique clarity that allowed us to follow their development inside the umbra,” he said. Previously believed to be diffuse patches randomly distributed over the umbra, the researchers found their location is in fact not random. They mainly form along so-called sunspot umbral light bridges, which are very large openings in the sunspot magnetic fields that often split an umbra into two or more parts.

“Even more importantly, we found that umbral flash lanes tend to appear on the side of light bridges that face the center of the sunspot,” he added. “This finding is significant because it indicates that sunspot oscillations may be driven by one energy source located under the umbra. There are simulations that appear to reproduce what we have observed, which is very encouraging. We, as a community, are finally in the position to be able to directly compare the observations and the state-of-the-art simulation results, which is the key to making further progress in our field.”

To view more images, click here.

For further information, contact Tracey Regan at NJIT at or 201-388-0232 or Craig DeForest, AAS/SPD press officer, at or 303-641-5769.

Wednesday, April 29, 2015

Ham radio attempts to fill communication gaps in Nepal rescue effort

A nice write-up outlining how Ham Radio has once again provided vital lifelines of communication to the people of Nepal.

Amateur radio has stepped in to fill communication gaps in Nepal, which is struggling with power outages and a flaky Internet after a devastating earthquake on Saturday killed over 5,000 people. Though 99 persons have ham licenses in Kathmandu, about eight use high-frequency (HF) radios that can transmit long distances, while another 30 have very high frequency and ultra high frequency sets for local traffic, said Satish Kharel, a lawyer in Kathmandu, who uses the ham call signal 9N1AA. The hobbyist radio operators are working round-the-clock to help people get in touch with relatives, pass on information and alert about developing crises.

If you have 8 minutes, take a look at the video below from MikesMovies. This shows the real life emergency net that was developed to help with Nepalese communications.

Wednesday, March 4, 2015

Lab grown quartz crystals: How its done.

Following up on yesterdays post regarding the manufacture of radio crystals from natural quartz crystals, I was able to find this video from the AT&T archives showing the relatively new, at the time, method of growing quartz crystals in the laboratory.

The video, produced in 1962, shows first the frustrating failures and ultimately the ability of Bell Labs staff to reliably produce the invaluable quartz crystals.

Very little of the technology we value today would have been possible without the hard work and perseverance of these early pioneers.

Tuesday, March 3, 2015

Crystals Go to War - 1943

One of the things that always fascinated me about radio was the ability to take discrete components and craft something that could pluck invisible radio signals out of the air. Once I learned more about electronics, some of the magic was replaced by admiration for the many generations of engineers and experimenters that had developed the radio art. Until recently, the theory behind crystals had not solidified (crystallized?) in my mind and so they remained one of those "mysterious devices".

The following film, like most produced during WWII, is a thorough explanation of the history and technology behind radio crystals. It was produced at a period when crystals were instrumental in securing reliable communications between military units, saving lives and coordinating the moment of supplies, troops and equipment.

I hope you'll find it as interesting as I did.