Arduino Notes

August 27th, 2016

Just a bunch of scattered Arduino notes.

Leonardo

leonardo-pinout

  • All data pins can be Digital Inputs or Outputs (i.e. D0-D13, A0-A5). Thus, 20 digital I/O pins
  • Caveat: D0 and D1 are shared by the UART bus used to communicate over USB. So if you want to avoid reading/writing weird values while connected to the PC, you may want to avoid these pins.
  • Pins D3, D5, D6, D9-D11, D13 have PWM’s attached to one of 3 (4) timers.
  • Timer1 (OC1x) on D9-D11 is the ‘fanciest’ timer. 😉
  • Pins A0-A5, as well as D4, D6, D8-10, D12 are all capable of Analog Input (not output)
  • To do analog out, use a PWM with some magic: https://arduino-info.wikispaces.com/Analog-Output
  • Each set of pins is a block. https://www.arduino.cc/en/Reference/PortManipulation
    • PORTD is D0-D7 (8 bits*, DDRD)
    • PORTB is D8-D13 (6 bits, DDRB)
    • PORTC is A0-A5 (6 bits, DDRC)
  • Set the DDRx registers directly to write bytes (i.e. DDRD = B11111100;). You can read them too, and mask-out the data you’re not using
  • B11001010 macros can be used for bitmasks, etc
  • PinMode(pin,mode) – mode can be INPUT, OUTPUT, or INPUT_PULLUP
  • INPUT_PULLUP not available on D0 and D1.
  • D0 and D1 are actually the same pins as SCL and SCA. On the board twice for some reason.
  • Standard 4 pins with support for interrupts D0-D3. Leonardo does actually have one more (D7)
  • Serial.print(), Serial.println() to output to the PC console over UART. https://www.arduino.cc/en/Reference/Serial

Protocols

UART

Has 1 channel. Not ‘true’ UART, as true UART runs at 12v.

  • Uses Pins D0 and D1 (because of interrupts).

1-Wire

For that temperature sensor (DS18B20).

  • Uses ??

I2C/TWI (2-Wire)

For a variety of breakout chips. 16bit ADC (ADS1115), DAC (MCP4725), 64k EEPROM (24LC512), 128k SRAM (23LC1024*), 16bit Digital I/O Expander (MCP23017)

  • Uses D2 and D3 (because of interrupts)

SPI (4-Wire)

For SD Cards, Flash Memory (W25Q80BV), 10bit ADC (MCP3008), …

  • ???

Notes: Benchmarking VPS Bandwidth

June 21st, 2016

Just a quick set of benchmarks, seeing how fast my servers are at downloading and uploading. These aren’t the be-all/end-all of benchmarks. They’re just a rough look at what the performance of a machine is.

The following test is used.

Linode, New Jersey: $10 VPS server, 1 core, 2 GB RAM

I’m pretty happy with these results. This machine has the fastest SSD I’ve tested, and provide a good benchmark for expected performance.

Scaleway, Paris: €3 dedicated server, 4 core ARM CPU, 2 GB RAM

One of the most interesting features of Scaleway is that you can get ARM powered servers. This is their €3 ARMv7 powered server with 4 cores and 2 GB of RAM. They don’t perform as well as Intel servers (about half the SSD performance), but they still do a really impressive job. I’m really excited about the future of this stuff.

Scaleway, Paris: €3 VPS server, 2 core (Atom Xeon), 2 GB of RAM

Their lowest end x86_64 powered server. At this price point you can’t use add-on storage, but the performance is really decent, especially given the price.

Due to its low cost, and decent performance and disk space (50 GB), I moved Delorian to one of these.

Scaleway, Paris: €24 dedicated server, 8 core (Atom Xeon), 32 GB of RAM, addon 250 GB SSD

The legacy Ludum Dare server. Given the price (a mere €24), and it being a fully dedicated server, I’m incredibly impressed by the performance. I really wish Scaleway had a domestic datacenter. I’m loving everything they’re doing.

Notes: Big Binary MySQL/MariaDB Logs

May 17th, 2016

MySQL/MariaDB has several log files.

https://dev.mysql.com/doc/refman/5.7/en/server-logs.html

Since moving Ludum Dare to a new server, I ran in to an issue where I was running out of hard drive space. Some details:

  • Ubuntu 14.04
  • MariaDB 10.1
  • WordPress, plus some custom stuff
  • 50 GB of SSD space (main partition)
  • 250 GB of additional SSD space (alt partition)

The database itself is on the alt partition, but I kept running out of main partition space.

Most Google searches for my problem talk of the regular log files eating space, but my problem was specifically the binary logs. The binary logs are used by the MySQL/MariaDB family of DB engines as both a log of actions, and for synchronized replication.

I discovered the hard drive full problem by running:

I also learned that on some Linuxes, when you run out of hard drive space, it may remap /tmp/ to RAM, but not very much RAM, so some temp files may fail to create because there isn’t enough space to store them. I had to free up some hard drive space and actually reboot to make it stop doing that. This is an automatic behaviour, so it’s simpler just to reboot to make in unmap the new /tmp/ partition.

The binary logs on Ubuntu are stored here:

And are given names like “mariadb-bin.002412“. You can find this mentioned in the my.cnf file as the “log_bin” basename.

Binary logs are actually automatically purged, at least in the default Ubuntu install of MariaDB. But the purge time is set to 10 days. With Ludum Dare, we so aggressively did things, that we found 10 days to be too much, and would run out of space.

I’ve since change “expire_log_days” to 3, as it was roughly every 4 days I had to clear the logs, so the website would return.

My temporary fix would invole going to the /var/log/mysql folder and deleting a bunch of files (because the mysql client can’t delete files if there is no hard drive space).

And to make sure it was internalized correctly, I would connect to the DB via the mysql client and run a:

Which should be self explanatory.

Notes: Mail Server Madness

March 20th, 2016

To avoid being flagged a spammer, your DNS server (and SMTP server) needs to be configured for:

  • PTR Records (Host)
  • SPF Records (DNS)
  • DKIM Records (DNS + SMTP)
  • DMARC Records (DNS + an email address)

Read the rest of this entry »

Using LetsEncrypt with OpenLiteSpeed on Ubuntu

March 9th, 2016

These notes are based on this.

Install GIT and BC.

Get the latest version of LetsEncrypt using GIT, placing it in /opt/.

For the next step, we’re going to need access to Port 80, so temporarily shut down your webserver.

Run LetsEncrypt.

The first time this runs, it’s going to ask for an e-mail address.

If everything worked correctly, you’ll find your certificate files here:

Where example.com is your domain name.

Next, inside your OpenLiteSpeed configuration, go in to your Listener->SSL settings. Add or modify them as follows:

Private Key: /etc/letsencrypt/live/example.com/privkey.pem
Certificate File: /etc/letsencrypt/live/example.com/fullchain.pem
Chained Certificate: Yes

The rest of the fields should be blank.

That’s it. Start the server.

Updating your certificates

Your certificate is good for 90 days, but it’s recommended you update it every 60.

Updating is exactly the same as requesting, and requires you free up Port 80!

That will overwrite the certificate. The new certificate will be good for another 90 days.

I haven’t automated this myself yet, but there are suggestions how to do this in the article linked at the top.

Project: Converting a PC power supply to a bench power supply

February 14th, 2016

So this will be an ongoing project.

I used to have some old PCs sitting in my closet. They take up a lot of space, and they’re heavy. So on a whim (as it always is), I decided to gut the PCs.

One of them, apparently I had already removed the power supply, so it was gone (if I remember, it was quite noisy, so no loss). The other still had its PSU, so I’ve selected it as the donor to my bench-top power supply project.

psu2

psu1

The PSU is effectively a 450 watt supply, more than enough for my needs. Also it’s one of the older supplies, so it appears to have a -5V wire (most modern supplies don’t have these anymore).

Reference

Here’s a video breakdown of ATX power supplies that seems quite informative.

http://www.instructables.com/id/ATX–%3E-Lab-Bench-Power-Supply-Conversion/?ALLSTEPS

http://www.instructables.com/id/A-Makers-Guide-to-ATX-Power-Supplies/?ALLSTEPS

Parts

I’m going to need parts. Banana plug sockets and some large resistors.

Something I’m thinking about doing is making one of these.

Sick of Beige basic case

Ultimately the goal is to make an all in one, but I’m tempted to try building an external board you can plug an unmodified power supply in to.

I’m going to steal connectors and things from a couple obsolete motherboards. I’m never going to use these computers again anyway, so why not put them to good use (instead of the trash).