This code is based on the example from Christopher Cope on his "Live Wi-Fi Water Meter Reader" project site.
http://seductiveequations.com/2015/11/09/water-meter.html
Connect the SDA/SCL/GND/Vin(3.3v) pins of the hmc5883l to the corresponding SDA/SCL/GND/3.3volt pins on the ESP8266 or ESP32 module you are using.