DIY NAS

NAS-BOX

A DIY NAS project from Peter Scargill:

So I’ve had a fair experience of these systems. Well, this blog entry isn’t about expensive NAS systems. It’s about a cheap one… really cheap that is – and DIY.
How cheap? Well, about £12 depending on what you have handy. For this price you need a handy 2.5” hard drive, a FriendlyArm NEO or NEO2 and of course the 1-Bay NAS Kit for NanoPi. Beware that the front panels for NEO and NEO2 are SLIGHTLY different – i.e. the Ethernet connection position varies slightly so these are not cross-compatible without a spot of filing which is why I’m showing you the stock photo!
Anyway… so I plugged my trusty 100GB 2.5” hard drive into the board (well, it was free and was sitting doing nothing), plugged the NEO2 into the board, downloaded the ROM and.. well, that was it really – turned on the power (you need a 12v power supply) and waited. Sure enough the unit appears on my network.

More details at Scargill’s Tech blog.

ATM90E36 Dev-kit for 3-phase AC metering

IMG_20170116_115148

Tisham Dhar blogged about his ATM90E36 3-phase energy monitor project:

After successfully building the single-phase energy monitor with the ATM90E26 there has been lots of interest in the 3-phase version. Being an open-hardware project, many people have created remixed and derived versions as well. After a while I started receiving requests to assist with the code for ATM90E36, the 3-phase version of the Energy Monitor chip. However I did not have the hardware to test the code, so I put together this basic devkit to access the SPI bus and easily inject voltage and CT signals to take the ATM90E36 through its paces. This is the first board I have designed based purely on user demand rather than to scratch my own itch, since I don’t have 3-phase supply at home.

Project info at Tisham Dhar’s blog.

Check out the video after the break.

8-bit assembler compiler project

8-bit assembler compiler

Dilshan Jayakody writes, “8-bit Assembler compiler is NASM compatible assembler compiler to generate binaries for 8-bit x86 like CPUs. The binaries produced with this compiler can execute on Marco Schweighauser’s 8-bit virtual Javascript CPU.
This native compiler can build using Lazarus / FPC. During the implementation we build and test this compiler successfully on Linux and Windows operating systems.”

More details at Dilshan Jayakody’s blog.

App note: Interfacing to analog switches: Driving the control input of an analog switch with 1.8 V or lower − Is it safe?

an_on_AND8304_D

ON Semiconductor’s analog switches let you drive with an input control voltage lower than Vcc. Link here (PDF)

Analog switches are everywhere today. Due to their small size and low current consumption, they are popular in portable devices where they are effective in a variety of subsystems including audio and data communications, port connections, and even test. They can be used to facilitate signal routing, allow multiple data types to share an interface connector, or permit temporary access to internal processors during manufacturing. Analog switches are often used to give portable system designers a convenient method of increasing their features or accessibility without duplicating any circuitry. Understanding the key specifications and tradeoffs can make the difference between a temporary fix and a truly optimized solution.

App note: Consideration of self-pollution reduction for electronic systems

an_on_AND9019-D

App note from ON Semiconductors discussing how locally generated EMI affects its own system and how to prevent it. Link here (PDF)

This application note will address the problem of Electro Magnetic Interference (EMI) self pollution in which one part of an electrical systems such as cell phones and consumer electrical products emit radiation that interferes with the operation of other parts of the system.

ESP32 (18) – Access Point

In all the examples so far, we used the esp32 chip in STAtion Mode, that is as a client which connects to an existing wifi network. In a previous article I explained in details how the different components of the esp-idf framework interact to establish the connection and how to use events to syncronize the tasks of your program.

Today you’ll learn how to configure the esp32 chip to publish its own wifi network, similar to an access point. This mode is indeed named SoftAP.

IP addressing

Every device connected to an IP network must have its unique address. You can statically assign the address or leverage a network service (DHCP, Dynamic Host Configuration Protocol) that dynamically assigns them. The main advantage in using the DHCP service is that you don’t need to know in advance – when connecting to a network – the correct settings to apply (IP address, netmask, gateway…); this is the reason why normally the device which manages the network also offers a DHCP server:

ap-05

The esp-idf framework does include a DHCP server. To use it in the network you’re going to create, you have to:

  • stop the service if it’s already running – tcpip_adapter_dhcps_stop()
  • statically configure the network interface of the esp32 chip – tcpip_adapter_set_ip_info()
  • start the service – tcpip_adapter_dhcps_start()

The esp-idf framework uses two different interfaces depending if the esp32 chip is in station mode or in SoftAP mode (TCPIP_ADAPTER_IF_STA e TCPIP_ADAPTER_IF_AP). Make sure you’re configuring the correct one based on the mode you’re planning to use.

For example, to assign the address 192.168.10.1/24 (/24 corresponds to 255.255.255.0 netmask) and run the DHCP server:

ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
tcpip_adapter_ip_info_t info;
memset(&info, 0, sizeof(info));
IP4_ADDR(&info.ip, 192, 168, 10, 1);
IP4_ADDR(&info.gw, 192, 168, 10, 1);
IP4_ADDR(&info.netmask, 255, 255, 255, 0);
ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &info));
ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));

SoftAP

Now you can configure the SoftAP mode for the esp32 chip.

First initialize the event handler (later I’ll list the events that are available when working in this mode):

ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));

Then configure the wifi stack in access point mode, with the default settings and RAM storage:

wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));

The different settings for the AP mode are available in the wifi_ap_config_t struct:

ap-01

  • ssid is the name (Service Set Identifier) of the network
  • password is the password you have to specify to connect to the network (if the authentication mode requires it, see below)
  • ssid_len is the length (in characters) of the ssid string – you can set it to zero if the string is null-terminated
  • channel is the transmission channel
  • authmode is the authentication mode, see paragraph below
  • ssid_hidden allows to “hide” the network not broadcasting its SSID
  • max_connection is the maximum number of concurrent connections (max 4)
  • beacon_intereval is the transmission interval for beacon frames

Once configured, you have to apply struct using the esp_wifi_set_config() method. In the example I published on Github, all the parameters can be configured via menuconfig:

ap-02

wifi_config_t ap_config = {
	.ap = {
		.ssid = CONFIG_AP_SSID,
		.password = CONFIG_AP_PASSWORD,
		.ssid_len = 0,
		.channel = CONFIG_AP_CHANNEL,
		.authmode = CONFIG_AP_AUTHMODE,
		.ssid_hidden = CONFIG_AP_SSID_HIDDEN,
		.max_connection = CONFIG_AP_MAX_CONNECTIONS,
		.beacon_interval = CONFIG_AP_BEACON_INTERVAL,			
	},
};
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));

Finally start the wifi stack with:

ESP_ERROR_CHECK(esp_wifi_start());

Events

Three are the main events available when working in access point mode:

  • SYSTEM_EVENT_AP_START, when the stack completed the start process (after esp_wifi_start)
  • SYSTEM_EVENT_AP_STACONNECTED, when a new device connects to the access point
  • SYSTEM_EVENT_AP_STADISCONNECTED, when a device disconnects

ap-03

In the example, the events are notified using different event bits:

case SYSTEM_EVENT_AP_START:
	printf("Access point started\n");
	break;
 
case SYSTEM_EVENT_AP_STACONNECTED:
	xEventGroupSetBits(event_group, STA_CONNECTED_BIT);
	break;
 
case SYSTEM_EVENT_AP_STADISCONNECTED:
	xEventGroupSetBits(event_group, STA_DISCONNECTED_BIT);
	break;

Authentication modes

In SoftAP mode, the esp32 chip supports different authentication modes:

ap-04

open configures a wifi network with no authentication, while all the other modes offer some security, from the “weak” ones (WEP, now easily hackable) to the strongest ones (WPA2). Personally, I always use the WPA2_PSK mode, which offers high security and authentication, using a shared password (PSK = PreShared Key).

Some authentication modes require a minimum password length. In particular, WPA and WPA2 require a password at least 8 characters long; if you specify a password too short, the esp_wifi_set_config method will return an error.

List the connected devices

You can get the list of the devices connected to the access point with the esp_wifi_ap_get_sta_list() method, which updates a wifi_sta_list_t struct:

wifi_sta_list_t wifi_sta_list;
memset(&wifi_sta_list, 0, sizeof(wifi_sta_list));
ESP_ERROR_CHECK(esp_wifi_ap_get_sta_list(&wifi_sta_list));

To obtain the IP settings (for example the address) of the different stations, you can then use the tcpip_adapter_get_sta_list() method:

tcpip_adapter_sta_list_t adapter_sta_list;
memset(&adapter_sta_list, 0, sizeof(adapter_sta_list));
ESP_ERROR_CHECK(tcpip_adapter_get_sta_list(&wifi_sta_list, &adapter_sta_list));
for(int i = 0; i < adapter_sta_list.num; i++) {
	tcpip_adapter_sta_info_t station = adapter_sta_list.sta[i];
	printf("%d - mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x - IP: %s\n", i + 1,
		station.mac[0], station.mac[1], station.mac[2],
		station.mac[3], station.mac[4], station.mac[5],
		ip4addr_ntoa(&(station.ip)));
}

Demo

A 2-channel receiver that can save your old Motorola TX

1featured-2

Boris Landoni writes about a new open source project 2-channel receiver that can save your old Motorola TX:

A 433,92 MHz Receiver that can be paired with a maximum of 10 Motorola TX each with relay outputs that can be set both in monostable or bistable mode.

Although we have had high security encoding for several years, based for instance on rolling-codes, a lot of remote controls and especially those installed long time ago in houses and other places for opening gates, are based on fixed and relatively simple encoding like the MM53200 of former National Semiconductor and the Motorola MC14502x; the latter had two new elements at the time of its introduction, that were the high (for the times) number of combinations allowed (19,683) and the three-state encoding (each encoding input of the encoder and of the decoder would allow three logic levels and required special three-state dip-switches).

More details at open-electronics.org.